<?php
/**
 * @author Administrator
 * @date 2022/11/19 17:14
 * @desciption:
 */

namespace JsonApi;


abstract class ObjectType extends \GraphQL\Type\Definition\ObjectType implements ObjectInterface
{

    const FIELDS_NAMESPACE      = 'App\GraphQL';
    const FIELDS_CLASS_SUFFIX   = 'Type';

    public function __construct(array $config)
    {
        $config["name"] = $this->getTypeName() . "#" . uniqid();
        parent::__construct($config);
    }

    public static function bind()
    {
        // TODO: Implement bind() method.
        return static::register();
    }

    protected function getTypeName(){
        $info   = explode("\\",get_called_class()) ?: [];
        $class  = array_pop($info);
        return str_replace(self::FIELDS_CLASS_SUFFIX,"",$class);
    }
}